<?php
	include("../header.php"); //header \
	include("../lib/header.php");
	include("../lib/function.php");
?>

<link rel="stylesheet" type="text/css" href="../style/style.css">
<script type="text/javascript">
	function show_popup(page)
	{
		child = open
		(
			"frm_list_pel.php",
			"",
			"scrollbars,width=400,height=400,left=150,top=150"
		);
	}
</script>
<br />
<title>Rekruitmen Pegawai</title>
<fieldset><legend>Rekruitmen Pegawai</legend>
<?
	include("../lib/config.php");
	$no_pel 	= $HTTP_POST_VARS['no_pel'];
	$nik_peg 	= $HTTP_POST_VARS['nik_peg'];
	$tombol		= $HTTP_POST_VARS['tombol'];
	
	if($tombol == "Simpan"){
		//echo "$no_pel, $nik_peg";
		// cek NIK di table Karyawan
		$nikcek	= mssql_query("SELECT * FROM Karyawan WHERE NIK='".$nik_peg."'",$conn);
		$cntr	= mssql_num_rows($nikcek);
		if($cntr > 0){
			echo"
			<div style='background-color: #EFEFEF; color: red; width: 100%;'>
			<center>
			<b>NIK Pegawai: $nik_peg  sudah ada dalam database</b>
			</center>
			</div>
			";	
		}
		else{
		// update table karyawan
		$upkar = mssql_query("UPDATE Karyawan SET NIK='$nik_peg', pelamar='0' WHERE NIK='$no_pel'",$conn);
		if($upkar){
			// update table pribadi
			$upprib = mssql_query("UPDATE Pribadi SET NIK='$nik_peg' WHERE NIK='$no_pel'",$conn);
			if($upprib){
				// update table pendidikan
				$uppend = mssql_query("UPDATE Pendidikan SET NIK='$nik_peg' WHERE NIK='$no_pel'",$conn);
				if($uppend){
					// update table kursus
					$upkur = mssql_query("UPDATE Kursus SET NIK='$nik_peg' WHERE NIK='$no_pel'",$conn);
					if($upkur){
						// update table sertifikat
						$upser = mssql_query("UPDATE MK_Certification SET NIK='$nik_peg' WHERE NIK='$no_pel'",$conn);
						if($upser){
							// update table bahasa/kecakapan
							$upbah = mssql_query("UPDATE Bahasa SET NIK='$nik_peg' WHERE NIK='$no_pel'",$conn);
							if($upbah){
								// update table keluarga
								$upkel = mssql_query("UPDATE Keluarga SET NIK='$nik_peg' WHERE NIK='$no_pel'",$conn);
								if($upkel){
									// update table karir / pengalaman
									$upkarir = mssql_query("UPDATE Karir SET NIK='$nik_peg' WHERE NIK='$no_pel'",$conn);
									if($upkarir){
										// update table relasi/hubungan
										$uprelasi = mssql_query("UPDATE PengalamanRef SET NIK='$nik_peg' WHERE NIK='$no_pel'",$conn);
										if($uprelasi){
											// update pengalaman luar negeri PengalamanLN
											$uppengln = mssql_query("UPDATE PengalamanLN SET NIK='$nik_peg' WHERE NIK='$no_pel'",$conn);
											if($uppengln){
												// update organisasi
												$uporg = mssql_query("UPDATE Organisasi SET NIK='$nik_peg' WHERE NIK='$no_pel'",$conn);
												if($uporg){
													// update dokumen
													$updok = mssql_query("UPDATE S_File_Emp SET NIK='$nik_peg' WHERE NIK='$no_pel'",$conn);
													if($updok){
														// update karir ptsi
														$upkarirptsi = mssql_query("UPDATE KarirPTSI SET NIK='$nik_peg' WHERE NIK='$no_pel'",$conn);
														if($upkarirptsi){
															// update sanksi
															$upsanksi = mssql_query("UPDATE Sanksi SET NIK='$nik_peg' WHERE NIK='$no_pel'",$conn);
															if($upsanksi){
															 // update track record
																$uptrack = mssql_query("UPDATE MK_TrackRecords SET NIK='$nik_peg' WHERE NIK='$no_pel'",$conn);
																if($uptrack){
																	// update penugasan
																	$uptgs = mssql_query("UPDATE Penugasan SET NIK='$nik_peg' WHERE NIK='$no_pel'",$conn);
																	if($uptgs){
																		echo"
																		<div style='background-color: #EFEFEF; width: 100%;'>
																		<center>
																		<b>Rekruitmen Pegawai Sudah Dilakukan</b>
																		</center>
																		</div>
																		";	
																	}
																}
															}
														}
													}
												}
											}
										}
									}
								}
							}
						}
					}
				}
			}
		}
		}
	}
?>
<form action="<?=$PHP_SELF?>" method="post">
<table border="0">
 <tr>
  <td>Silahkan masukkan No. Pelamar:</td>
  <td><input type="text" name="no_pel" readonly> <a href='Javascript:show_popup()'><img src='../images/people.png' border=0></a></td>
 </tr>
 <tr>
  <td>&nbsp;</td>
  <td><input type="text" value="" name="nama" size="35" readonly></td>
 </tr>
 <tr>
  <td>Silahkan masukkan NIK pegawai:</td>
  <td><input type="text" size="15" maxlength="10" name="nik_peg"></td>
 </tr>
 <tr>
  <td>&nbsp;</td>
  <td><input type="reset" value="Clear" onclick="Javascript:window.close();" class="button" /><input type="submit" name="tombol" value="Simpan" class="button"></td>
 </tr>
</table>
</form>
</fieldset>
<?php
echo"</div>
	  </td>
	   </tr>
	    </table>
";

include "../menu.php";
?>